﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Garden.Model;
using Kaixin.BLL;
using Kaixin.BLL.Helper;

namespace Garden.Func
{
    abstract class WorkMan:IWork
    {

        /// <summary>
        /// 工作满足条件
        /// </summary>
        /// <returns></returns>
        protected abstract bool WorkCondition(Farmland land);
        /// <summary>
        /// 工作总结
        /// </summary>
        protected abstract void WorkSummary(Farmland land,LogWrite log,string data);
        /// <summary>
        /// 请求页面
        /// </summary>
        protected string WhichPage = string.Empty;

        public void DoWork(Farmland land, LogWrite log, string verify)
        {
            if (WorkCondition(land))
            {

                string url =
                    string.Format(
                        "http://www.kaixin001.com/!house/!garden/{4}.php?fuid={0}&seedid={1}&farmnum={2}&verify={3}&r=0.2959122322499752",
                        land.UID,
                        land.Seed.ID,
                        land.FarmNum, verify, WhichPage);
                string dataXML = WebHelper.Get(url);
                WorkSummary(land,log, dataXML);
            }
        }
    }
}
